<template>
  <div class="app-container">
    <!-- 搜索和操作区域保持不变 -->
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="食谱名称" prop="recipeName">
        <el-input
          v-model="queryParams.recipeName"
          placeholder="请输入食谱名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      :data="recipeList"
      v-loading="loading"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" type="index" width="50" align="center" />
      <el-table-column prop="recipeName" label="食谱名称" align="center" />
      <el-table-column prop="userName" label="咨询人" align="center" />
      <el-table-column prop="createTime" label="创建时间" align="center">
        <template #default="scope">
          {{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}
        </template>
      </el-table-column>
      <el-table-column
        prop="remark"
        label="备注"
        show-overflow-tooltip
        align="center"
      />
      <el-table-column
        prop="consultBody"
        label="咨询内容"
        align="center"
        show-overflow-tooltip
      />
      <el-table-column
        prop="consultTime"
        label="咨询时间"
        align="center"
        width="160px"
      >
        <template #default="scope">
          {{ parseTime(scope.row.consultTime, "{y}-{m}-{d} {h}:{m}:{s}") }}
        </template>
      </el-table-column>
      <el-table-column prop="suggestBody" label="建议内容" align="center" />
      <el-table-column label="操作" align="center" width="220px">
        <template #default="scope">
          <el-button
            size="small"
            type="primary"
            @click="handleDetail(scope.row)"
            v-hasPermi="['manage:recipe:edit']"
            >查看</el-button
          >
          <el-button
            size="small"
            type="success"
            @click="openCommentDialog(scope.row)"
            v-hasPermi="['manage:recipe:edit']"
            >评论</el-button
          >
          <el-button
            size="small"
            type="warning"
            @click="openRatingDialog(scope.row)"
            v-hasPermi="['manage:recipe:edit']"
            v-if="getCurrentUser(scope.row)"
            >反馈</el-button
          >
        </template>
      </el-table-column>
      <template #empty>
    <el-empty description="暂无数据" />
  </template>
    </el-table>

    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改食谱管理对话框 -->
    <el-dialog :title="title" v-model="open" width="550px" append-to-body>
      <el-form ref="recipeRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="食谱名称" prop="recipeName">
          <el-input v-model="form.recipeName" placeholder="请输入食谱名称" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
            type="textarea"
            :rows="2"
            v-model="form.remark"
            placeholder="请输入备注"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 查看食谱管理对话框 -->
    <el-dialog :title="title" v-model="detailOpen" width="600px" append-to-body>
      <el-tabs v-model="activeDetailTab" type="card" class="detail-tabs">
        <!-- 早餐食谱 -->
        <el-tab-pane label="早餐" name="breakfast">
          <div
            v-for="(item, index) in detailRecipe.breakfastRecipe"
            :key="`breakfast-${index}`"
            class="recipe-item"
          >
            <p><strong>食材名称：</strong>{{ item.foodName }}</p>
            <p><strong>备注：</strong>{{ item.remark }}</p>
          </div>
        </el-tab-pane>

        <!-- 午餐食谱 -->
        <el-tab-pane label="午餐" name="lunch">
          <div
            v-for="(item, index) in detailRecipe.lunchRecipe"
            :key="`lunch-${index}`"
            class="recipe-item"
          >
            <p><strong>食材名称：</strong>{{ item.foodName }}</p>
            <p><strong>备注：</strong>{{ item.remark }}</p>
          </div>
        </el-tab-pane>

        <!-- 晚餐食谱 -->
        <el-tab-pane label="晚餐" name="dinner">
          <div
            v-for="(item, index) in detailRecipe.dinnerRecipe"
            :key="`dinner-${index}`"
            class="recipe-item"
          >
            <p><strong>食材名称：</strong>{{ item.foodName }}</p>
            <p><strong>备注：</strong>{{ item.remark }}</p>
          </div>
        </el-tab-pane>

        <el-tab-pane label="建议" name="suggestion">
          <el-form-item label="建议内容" class="suggest-input">
            <el-input
              type="textarea"
              :rows="5"
              v-model="detailRecipe.suggestBody"
              placeholder="无建议内容"
              resize="none"
              readonly
            />
          </el-form-item>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <!-- 评论对话框 -->
    <el-dialog
      v-model="commentDialogVisible"
      width="600px"
      title="评论"
      append-to-body
    >
      <div class="comment-container">
        <!-- 评论列表 -->
        <div class="comment-list">
          <el-empty v-if="commentList.length === 0" description="暂无评论" />
          <div
            v-for="comment in commentList"
            :key="comment.commentId"
            class="comment-item"
          >
            <!-- 一级评论 -->
            <div class="comment-main">
              <div class="comment-header">
                <el-image
                  :src="comment.avatar"
                  style="width: 32px; height: 32px; border-radius: 50%"
                  fit="cover"
                />
                <span class="comment-user">{{ comment.userName }}</span>
              </div>
              <div class="comment-content">
                <div class="comment-body">{{ comment.commentBody }}</div>
                <div class="comment-footer">
                  <span class="comment-time">
                    {{ parseTime(comment.createTime, "{y}-{m}-{d} {h}:{m}") }}
                  </span>
                  <span style="margin-left: 10px;">{{
                      comment.ipAddr
                      }}</span>
                  <div class="comment-actions">
                    <el-button
                      type="text"
                      size="small"
                      @click.stop="handleReply(comment)"
                    >
                      回复
                    </el-button>
                  </div>
                </div>
              </div>
            </div>

            <!-- 二级评论 -->
            <template
              v-if="
                comment.commentChildList && comment.commentChildList.length > 0
              "
            >
              <!-- 默认显示第一条二级评论 -->
              <div class="comment-child">
                <div class="comment-header">
                  <el-image
                    :src="comment.commentChildList[0].avatar"
                    style="width: 32px; height: 32px; border-radius: 50%"
                    fit="cover"
                  />
                  <span class="comment-user">{{
                    comment.commentChildList[0].userName
                  }}</span>
                </div>
                <div class="comment-content">
                  <div class="comment-body">
                    {{
                      comment.commentChildList[0].toUserName
                        ? `回复 ${comment.commentChildList[0].toUserName}：${comment.commentChildList[0].commentBody}`
                        : comment.commentChildList[0].commentBody
                    }}
                  </div>
                  <div class="comment-footer">
                    <span>{{
                      parseTime(
                        comment.commentChildList[0].createTime,
                        "{y}-{m}-{d}"
                      )
                    }}</span>
                    <span style="margin-left: 10px;">{{
                      comment.ipAddr
                      }}</span>
                    <div class="comment-actions">
                      <el-button
                        type="text"
                        size="small"
                        @click.stop="handleReply(comment.commentChildList[0])"
                      >
                        回复
                      </el-button>
                    </div>
                  </div>
                </div>
              </div>

              <!-- 折叠的其他二级评论 -->
              <div
                v-if="comment.commentChildList.length > 1 && !comment.expanded"
                class="show-more-comments"
              >
                <el-button type="text" @click="expandComments(comment)">
                  展开{{ comment.commentChildList.length - 1 }}条回复
                </el-button>
              </div>

              <!-- 展开的其他二级评论 -->
              <template v-if="comment.expanded">
                <div
                  v-for="(child, index) in comment.commentChildList"
                  :key="child.commentId"
                  class="comment-child"
                  v-show="index > 0"
                >
                  <div class="comment-header">
                    <el-image
                      :src="child.avatar"
                      style="width: 32px; height: 32px; border-radius: 50%"
                      fit="cover"
                    />
                    <span class="comment-user">{{ child.userName }}</span>
                  </div>
                  <div class="comment-content">
                    <div class="comment-body">
                      {{
                        child.toUserName
                          ? `回复 ${child.toUserName}：${child.commentBody}`
                          : child.commentBody
                      }}
                    </div>
                    <div class="comment-footer">
                      <span>{{
                        parseTime(child.createTime, "{y}-{m}-{d}")
                      }}</span>
                      <span style="margin-left: 10px;">{{
                        child.ipAddr
                      }}</span>
                      <div class="comment-actions">
                        <el-button
                          type="text"
                          size="small"
                          @click.stop="handleReply(child)"
                        >
                          回复
                        </el-button>
                      </div>
                    </div>
                  </div>
                </div>
              </template>
            </template>
          </div>
        </div>

        <!-- 评论输入区域 -->
        <div
          class="comment-input-area"
          :class="{ expanded: isCommentExpanded }"
        >
          <!-- 新增回复信息展示 -->
          <div v-if="replyTarget" class="reply-info">
            <div class="reply-title">回复 {{ replyTarget.userName }}</div>
            <div class="reply-content">{{ replyTarget.commentBody }}</div>
            <el-icon class="close-reply" @click="cancelReply"
              ><Close
            /></el-icon>
          </div>

          <div @click="!isCommentExpanded && toggleCommentInput()">
            <el-input
              v-model="newComment"
              placeholder="点击输入评论..."
              readonly
              v-if="!isCommentExpanded"
            />
            <div v-else class="expanded-input">
              <el-input
                v-model="newComment"
                type="textarea"
                :rows="4"
                placeholder="输入评论..."
                resize="none"
                @click.stop
              />
              <div class="input-actions">
                <el-button size="small" @click.stop="addComment"
                  >提交</el-button
                >
                <el-button size="small" type="text" @click.stop="cancelReply"
                  >取消</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>

    <el-dialog
  v-model="ratingDialogVisible"
  title="反馈"
  width="500px" 
  append-to-body
>
  <div class="rating-container">
    <el-rate
      v-model="star"
      :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
      allow-half
    />
  </div>
  <div class="feedback-textarea">
    <el-input
      v-model="feedbackBody"
      type="textarea"
      :rows="4"
      placeholder="请输入您的反馈意见"
      maxlength="250"
      show-word-limit
      resize="none"
    />
  </div>
  <template #footer>
    <div class="dialog-footer">
      <el-button @click="ratingDialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitRating">确 定</el-button>
    </div>
  </template>
</el-dialog>
  </div>
</template>

<script setup name="FeedBack">
import { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe, batchUpdateRecipe, listComment, insertComment } from "@/api/manage/recipe"
import { listFood } from "@/api/manage/food"
import useUserStore from '@/store/modules/user'

const userStore = useUserStore()

const { proxy } = getCurrentInstance()
const recipeList = ref([])
const open = ref(false)
const detailOpen = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const detailRecipe = ref({})
const activeDetailTab = ref('breakfast')

const data = reactive({
  form: {
    breakfastList: [],
    lunchList: [],
    dinnerList: []
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    recipeName: null,
    consultFlag: null
  },
  rules: {
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询食谱管理列表 */
function getList () {
  loading.value = true
  queryParams.value.consultFlag = 2
  listRecipe(queryParams.value).then(response => {
    recipeList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel () {
  open.value = false
  reset()
}

// 表单重置
function reset () {
  form.value = {
    recipeId: null,
    recipeName: null,
    breakfastRecipe: null,
    lunchRecipe: null,
    dinnerRecipe: null,
    userId: null,
    createTime: null,
    breakfastList: [],
    lunchList: [],
    dinnerList: []
  }
  proxy.resetForm("recipeRef")
}

/** 搜索按钮操作 */
function handleQuery () {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery () {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange (selection) {
  // ids为多选框选中的未通过审批的id
  ids.value = selection.map(item => {
    if (item.verifyFlag === 0) {
      return item.recipeId
    }
  })
  single.value = selection.length !== 1
  multiple.value = !selection.length
}

function handleAllVerify () {
  proxy.$modal.confirm('确定要一键审批选中的食谱吗？').then(function () {
    return batchUpdateRecipe(ids.value)
  }).then(res => {
    getList()
    if (res.code === 200) {
      proxy.$modal.msgSuccess("一键审批成功")
    }
  }).catch(() => { })
}

/** 新增按钮操作 */
function handleAdd () {
  reset()
  open.value = true
  title.value = "添加食谱管理"
}

/** 修改按钮操作 */
function handleUpdate (row) {
  reset()
  const _recipeId = row.recipeId || ids.value
  getRecipe(_recipeId).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改食谱管理"
  })
}

/** 查看按钮操作 */
function handleDetail (recipe) {
  const _recipeId = recipe.recipeId || ids.value
  getRecipe(_recipeId).then(response => {
    detailRecipe.value = response.data
    // 将json转换为数组
    detailRecipe.value.breakfastRecipe = JSON.parse(detailRecipe.value.breakfastRecipe || '[]')
    detailRecipe.value.lunchRecipe = JSON.parse(detailRecipe.value.lunchRecipe || '[]')
    detailRecipe.value.dinnerRecipe = JSON.parse(detailRecipe.value.dinnerRecipe || '[]')
    // 确保建议内容被正确赋值
    detailRecipe.value.suggestBody = response.data.suggestBody || ''
    // 重置activeTab为默认值
    activeDetailTab.value = 'breakfast'
    detailOpen.value = true
    title.value = "食谱详情"
  })
}

/** 提交按钮 */
function submitForm () {
  proxy.$refs["recipeRef"].validate(valid => {
    if (valid) {
      if (form.value.recipeId != null) {
        updateRecipe(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        // 提取数据
        const recipeData = {}
        recipeData.recipeName = form.value.recipeName
        recipeData.remark = form.value.remark
        // 移除 popoverVisible 字段并转换为 JSON 字符串
        recipeData.breakfastRecipe = JSON.stringify(
          form.value.breakfastList.map(item => {
            const { popoverVisible, ...rest } = item // 解构赋值，移除 popoverVisible
            return rest
          })
        )
        recipeData.lunchRecipe = JSON.stringify(
          form.value.lunchList.map(item => {
            const { popoverVisible, ...rest } = item // 解构赋值，移除 popoverVisible
            return rest
          })
        )
        recipeData.dinnerRecipe = JSON.stringify(
          form.value.dinnerList.map(item => {
            const { popoverVisible, ...rest } = item // 解构赋值，移除 popoverVisible
            return rest
          })
        )
        addRecipe(recipeData).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete (row) {
  const _recipeIds = row.recipeId || ids.value
  const delName = _recipeIds.length >= 1 ? '选中的食谱' : row.recipeName
  proxy.$modal.confirm('确定要删除' + delName + '吗？').then(function () {
    return delRecipe(_recipeIds)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => { })
}

// 新增进食记录
function handleAddItem (mealType) {
  if (mealType === 'breakfast') {
    form.value.breakfastList.push({})
  } else if (mealType === 'lunch') {
    form.value.lunchList.push({})
  } else {
    form.value.dinnerList.push({})
  }
}

// 删除进食记录
function handleRemoveItem (index, mealType) {
  if (mealType === 'breakfast') {
    form.value.breakfastList.splice(index, 1)
  } else if (mealType === 'lunch') {
    form.value.lunchList.splice(index, 1)
  } else {
    form.value.dinnerList.splice(index, 1)
  }
}

const foodList = ref([])

// 获取食材列表
function getFoodList () {
  listFood().then(response => {
    foodList.value = response.rows
  })
}

const commentDialogVisible = ref(false)
const currentItem = ref({})
const commentList = ref([])
const newComment = ref('')
const isCommentExpanded = ref(false)
const replyTarget = ref(null)

// 展开评论
function expandComments (comment) {
  comment.expanded = true
}

// 打开评论对话框时获取评论列表
function openCommentDialog (item) {
  currentItem.value = item
  listComment(item.recipeId).then(res => {
    // 为每条评论添加expanded属性
    commentList.value = res.data.map(comment => ({
      ...comment,
      expanded: false
    }))
  })
  commentDialogVisible.value = true
}

// 提交评论
function addComment () {
  if (!newComment.value.trim()) {
    proxy.$modal.msgWarning('评论内容不能为空')
    return
  }

  const data = {
    recipeId: currentItem.value.recipeId,
    commentBody: newComment.value
  }

  // 如果有回复目标，添加回复相关信息
  if (replyTarget.value) {
    // 将replyTarget.value的所有属性添加到data，除了commentBody
    Object.assign(data, replyTarget.value, { commentBody: newComment.value })
  }

  insertComment(data).then(() => {
    proxy.$modal.msgSuccess('评论成功')
    newComment.value = ''
    replyTarget.value = null
    // 重新获取评论列表
    openCommentDialog(currentItem.value)
  })
}

// 回复评论
function handleReply (comment) {
  replyTarget.value = comment
  isCommentExpanded.value = true
}

// 取消回复
function cancelReply () {
  newComment.value = ''
  replyTarget.value = null
  toggleCommentInput()
}

const commentSectionHeight = ref('calc(100% - 60px)')  // 初始高度

// 切换评论输入框展开状态
const toggleCommentInput = () => {
  isCommentExpanded.value = !isCommentExpanded.value
  // 如果需要调整高度
  commentSectionHeight.value = isCommentExpanded.value
    ? 'calc(100% - 200px)'
    : 'calc(100% - 60px)'
  // 关闭时同时清除回复目标
  if (!isCommentExpanded.value) {
    replyTarget.value = null
  }
}

const ratingDialogVisible = ref(false)
const star = ref(0)
const currentRatingItem = ref(null)
const feedbackBody = ref('')

// 打开评分对话框
function openRatingDialog(item) {
  currentRatingItem.value = item
  // 获取食谱详情时同时获取评分数据
  getRecipe(item.recipeId).then(response => {
    star.value = response.data.star || 0
    feedbackBody.value = response.data.feedbackBody || '' // 回显已有反馈文本
    ratingDialogVisible.value = true
  })
}

// 提交评分
function submitRating() {
  if (!currentRatingItem.value) return

  const data = {
    recipeId: currentRatingItem.value.recipeId,
    star: star.value,
    feedbackBody: feedbackBody.value // 添加反馈文本
  }

  updateRecipe(data).then(() => {
    proxy.$modal.msgSuccess("反馈成功")
    feedbackBody.value = '' // 清空反馈文本
    ratingDialogVisible.value = false
  }) 
}

const getCurrentUser = (item) => {
  return userStore.getInfo().then(userInfo => {
    console.log(userInfo.user)
    return userInfo.user.userId === item.userId
  }).catch(error => {
    return false
  })
}

getList()
getFoodList();
</script>

<style lang="scss" scoped>
.recipe-item {
  position: relative;
  padding: 10px;
  border: 1px solid #ebeef5;
  border-radius: 4px;
  margin-bottom: 10px;
}

.recipe-item .el-form-item {
  margin-bottom: 15px;
  width: calc(100% - 70px);
}

.delete-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.add-btn-container {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.meal-detail {
  padding: 10px;
}

.meal-item {
  margin-bottom: 10px;
}

.meal-item p {
  margin: 5px 0;
  font-size: 14px;
}

.comment-container {
  padding: 10px;
  height: 500px; /* 固定高度 */
  display: flex;
  flex-direction: column;
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
}

.comment-footer {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #999;
  margin-left: 40px;
}

.comment-input-area {
  margin-top: 20px;
}

.comment-child {
  margin-left: 30px;
  padding: 10px;
  border-radius: 4px;
}

.show-more-comments {
  margin-left: 40px;
  margin-top: 5px;
}

.reply-info {
  background: #f5f7fa;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
  position: relative;
}

.reply-title {
  font-size: 12px;
  color: #666;
}

.reply-content {
  font-size: 13px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.close-reply {
  position: absolute;
  right: 8px;
  top: 8px;
  cursor: pointer;
}

.expanded-input {
  margin-top: 10px;
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.comment-input-area {
  position: relative;
  padding: 12px;
  background: white;
  border-top: 1px solid #ebeef5;
  transition: all 0.3s ease;
  z-index: 10;

  &:not(.expanded) {
    height: 60px;
    cursor: pointer;

    :deep(.el-input__inner) {
      cursor: pointer;
    }
  }

  &.expanded {
    height: 200px;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.1);

    .expanded-input {
      height: calc(100% - 40px); /* 留出按钮空间 */
      display: flex;
      flex-direction: column;

      :deep(.el-textarea__inner) {
        flex: 1;
        margin-bottom: 8px;
      }
    }
  }
}

.reply-info {
  position: relative;
  background-color: #f5f7fa;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-left: 3px solid #409eff;

  .reply-title {
    font-size: 13px;
    color: #409eff;
    font-weight: 500;
  }

  .reply-content {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .close-reply {
    position: absolute;
    right: 8px;
    top: 8px;
    cursor: pointer;
    color: #999;
    font-size: 14px;

    &:hover {
      color: #666;
    }
  }
}

.rating-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
  
  :deep(.el-rate__icon) {
    margin-right: 20px;
    font-size: 30px;
  }
}

.feedback-textarea {
  padding: 0 20px 20px;
  
  :deep(.el-textarea__inner) {
    font-size: 14px;
  }
}

.comment-header {
  display: flex;
  align-items: center;
  min-width: 44px;
}

.comment-user {
  font-size: 13px;
  color: #606266;
  margin-top: 4px;
  margin-left: 8px;
}

.comment-content {
  flex: 1;
  padding-top: 2px; // 让内容与头像顶部对齐
}

.comment-body {
  font-size: 14px;
  line-height: 1.5;
  margin-left: 40px;
}

.comment-child {
  margin-left: 56px; // 增加缩进距离
  padding: 10px;
  border-radius: 4px;
  margin-top: 8px;
}
</style>